package com.edu.exam.entity.examination.paper.technical;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import jakarta.persistence.*;
import java.time.LocalDateTime;
import com.edu.exam.enums.examination.paper.PaperProcessingTaskStatus;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

/**
 * 扫描识别任务实体类
 * [所属模块] E-04 扫描阅卷处理模块
 * 对应数据库表：scan_recognition_task
 *
 * 根据E-04扫描阅卷处理模块设计实现
 * 管理扫描识别任务的基本信息和管理数据。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class ScanRecognitionTask {

    /**
     * 任务ID，主键
     */
    @Id
    @Column(name = "task_id", length = 64)
    private String taskId;

    /**
     * 批次ID
     */
    @Column(name = "batch_id", length = 64, nullable = false)
    private String batchId;

    /**
     * 考试ID
     */
    @Column(name = "exam_id", length = 64, nullable = false)
    private String examId;

    /**
     * 模板ID
     */
    @Column(name = "template_id", length = 64, nullable = false)
    private String templateId;

    /**
     * 任务状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "task_status", length = 32, nullable = false)
    private PaperProcessingTaskStatus taskStatus;

    /**
     * 总图片数量
     */
    @Column(name = "total_images", nullable = false)
    private Integer totalImages;

    /**
     * 已处理图片数量
     */
    @Column(name = "processed_images", nullable = false)
    private Integer processedImages;

    /**
     * 失败图片数量
     */
    @Column(name = "failed_images", nullable = false)
    private Integer failedImages;

    /**
     * 开始时间
     */
    @Column(name = "start_time", nullable = false)
    private LocalDateTime startTime;

    /**
     * 结束时间
     */
    @Column(name = "end_time")
    private LocalDateTime endTime;

    /**
     * 处理耗时（毫秒）
     */
    @Column(name = "processing_time")
    private Long processingTime;

    /**
     * 创建人ID
     */
    @Column(name = "created_by", length = 64, nullable = false)
    private String createdBy;

    // ===== 标准审计字段 =====

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 版本号（乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Long version = 0L;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

}